package com.lang.downloader.http.header;

import lombok.Getter;
import lombok.Setter;

/**
 * 请求头
 */
@Getter
@Setter
public class HttpRequestHeader extends HttpRequestHeaderKeySet implements Cloneable {

    @HttpHeader(name = "Accept", description = "指定客户端能够接收的内容类型")
    private String accept;

    @HttpHeader(name = "Accept-Charset", description = "浏览器可以接受的字符编码集")
    private String acceptCharset;

    @HttpHeader(name = "Accept-Encoding", description = "指定浏览器可以支持的web服务器返回内容压缩编码类型")
    private String acceptEncoding;

    @HttpHeader(name = "Accept-Language", description = "浏览器可接受的语言")
    private String acceptLanguage;

    @HttpHeader(name = "Accept-Ranges", description = "可以请求网页实体的一个或者多个子范围字段")
    private String acceptRanges;

    @HttpHeader(name = "Authorization", description = "HTTP授权的授权证书")
    private String authorization;

    @HttpHeader(name = "Cache-Control", description = "指定请求和响应遵循的缓存机制")
    private String cacheControl;

    @HttpHeader(name = "Connection", description = "表示是否需要持久连接。（HTTP 1.1默认进行持久连接）")
    private String connection;

    @HttpHeader(name = "Cookie", description = "HTTP请求发送时，会把保存在该请求域名下的所有cookie值一起发送给web服务器")
    private String cookie;

    @HttpHeader(name = "Content-Length", description = "请求的内容长度")
    private String contentLength;

    @HttpHeader(name = "Content-Type", description = "请求的与实体对应的MIME信息")
    private String contentType;

    @HttpHeader(name = "Date", description = "请求发送的日期和时间")
    private String date;

    @HttpHeader(name = "Expect", description = "请求的特定的服务器行为")
    private String expect;

    @HttpHeader(name = "From", description = "发出请求的用户的Email")
    private String from;

    @HttpHeader(name = "Host", description = "指定请求的服务器的域名和端口号")
    private String host;

    @HttpHeader(name = "If-Match", description = "只有请求内容与实体相匹配才有效")
    private String ifMatch;

    @HttpHeader(name = "If-Modified-Since", description = "如果请求的部分在指定时间之后被修改则请求成功，未被修改则返回304代码")
    private String ifModifiedSince;

    @HttpHeader(name = "If-None-Match", description = "如果内容未改变返回304代码，参数为服务器先前发送的Etag，与服务器回应的Etag比较判断是否改变")
    private String ifNoneMatch;

    @HttpHeader(name = "If-Range", description = "如果实体未改变，服务器发送客户端丢失的部分，否则发送整个实体。参数也为Etag")
    private String ifRange;

    @HttpHeader(name = "If-Unmodified-Since", description = "只在实体在指定时间之后未被修改才请求成功")
    private String ifUnmodifiedSince;

    @HttpHeader(name = "Max-Forwards", description = "限制信息通过代理和网关传送的时间")
    private String maxForwards;

    @HttpHeader(name = "Pragma", description = "用来包含实现特定的指令")
    private String pragma;

    @HttpHeader(name = "Proxy-Authorization", description = "连接到代理的授权证书")
    private String proxyAuthorization;

    @HttpHeader(name = "Range", description = "只请求实体的一部分，指定范围")
    private String range;

    @HttpHeader(name = "Referer", description = "先前网页的地址，当前请求网页紧随其后,即来路")
    private String referer;

    @HttpHeader(name = "TE", description = "客户端愿意接受的传输编码，并通知服务器接受接受尾加头信息")
    private String te;

    @HttpHeader(name = "Upgrade", description = "向服务器指定某种传输协议以便服务器进行转换（如果支持）")
    private String upgrade;

    @HttpHeader(name = "User-Agent", description = "User-Agent的内容包含发出请求的用户信息")
    private String userAgent;

    @HttpHeader(name = "Via", description = "通知中间网关或代理服务器地址，通信协议")
    private String via;

    @HttpHeader(name = "Warning", description = "关于消息实体的警告信息")
    private String warning;

    public static HttpRequestHeader defaultHeader() {
        HttpRequestHeader requestHeader = new HttpRequestHeader();
        requestHeader.setUserAgent("Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36");
        requestHeader.setAccept("application/json, text/plain, */*");
        requestHeader.setAcceptCharset("UTF-8");
        requestHeader.setAcceptLanguage("zh-CN,zh;q=0.9");
        return requestHeader;
    }

    @Override
    public HttpRequestHeader clone() throws CloneNotSupportedException {
        return (HttpRequestHeader) super.clone();
    }

}
